package com.imut.controller;

import com.imut.entity.Publisher;
import com.imut.service.PublisherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/publisher")
public class PublisherContorller {
    @Autowired
    private PublisherService publisherService;

    @PostMapping
    public ResponseEntity<Boolean> insertAll(@RequestBody Publisher publisher) {
        return ResponseEntity.ok(publisherService.insertAll(publisher));
    }

    @PutMapping
    public ResponseEntity<Boolean> updateById(@RequestBody Publisher publisher) {
        return ResponseEntity.ok(publisherService.updateById(publisher));
    }

    @DeleteMapping("/{id}")
    public ResponseEntity<Boolean> deleteById(@PathVariable Integer id) {
        return ResponseEntity.ok(publisherService.deleteById(id));
    }

    @GetMapping("/{id}")
    public ResponseEntity<Publisher> selectById(@PathVariable Integer id) {
        return ResponseEntity.ok(publisherService.selectById(id));
    }

    @GetMapping
    public ResponseEntity<List<Publisher>> selectAll(@RequestBody Publisher publisher) {
        return ResponseEntity.ok(publisherService.selectAll(publisher));
    }
}
